package cn.edu.seig.textbook.service.impl;

import cn.edu.seig.textbook.domain.pojo.Textbooks;
import cn.edu.seig.textbook.mapper.TextbooksMapper;
import cn.edu.seig.textbook.service.ITextbooksService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author day
 * @since 2024-11-07
 */
@Service
public class TextbooksServiceImpl extends ServiceImpl<TextbooksMapper, Textbooks> implements ITextbooksService {
    @Autowired
    private TextbooksMapper textbooksMapper;

    @Override
    public List<Textbooks> getAllTestbooks(){
        return textbooksMapper.getAllTextbooks();
    }

    @Override
    public Textbooks getTextbookById(int textbookId){
        return textbooksMapper.getTextbookById(textbookId);
    }

    @Override
    public List<Textbooks> getTextbooksByCourseName(String courseName){
        return textbooksMapper.getTextbooksByCourseName(courseName);
    }

    @Override
    public boolean addTextbook(Textbooks textbook){
        return textbooksMapper.insertOrUpdate(textbook);
    }

    @Override
    public void deleteTextbook(int textbookId) {
        textbooksMapper.deleteById(textbookId);
    }

    @Override
    public List<Textbooks> getTextbooksByBookName(String bookName) {
        return textbooksMapper.getTextbooksByBookName(bookName);
    }

}
